﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;

namespace LIT.Logger.ServerChecker
{
    partial class ServerCheckerSvc : ServiceBase
    {
        Timer m_timer;
        Timer m_eventLogTimer;

        public ServerCheckerSvc()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            int periodDefault = Properties.Settings.Default.CheckFrequencyMin * 60 * 1000;
            m_timer = new Timer(new TimerCallback(Tick), null, 0, periodDefault );
            int periodEventLog = Properties.Settings.Default.EventLogCheckFrequency * 60 * 1000;
            m_eventLogTimer = new Timer(new TimerCallback(TickEventLog), null, 0, periodEventLog);
        }

        private void Tick(object _state)
        {
            LIT.Logger.ServerCheckerBL.ServerLogProcessor.Process();
        }

        private void TickEventLog(object _state)
        {
            LIT.Logger.ServerCheckerBL.ServerLogProcessor.ProcessEventLog();
        }

        protected override void OnStop()
        {
            m_timer.Dispose();
            m_eventLogTimer.Dispose();
        }
    }
}
